﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Editor;
using ESRI.ArcGIS.EditorExt;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.GlobeCore;
using ESRI.ArcGIS.NetworkAnalysis;
using ESRI.ArcGIS.Output;
using ESRI.ArcGIS.SystemUI;
using DIWAGIS.Class;
using DIWAGIS.Modules;
namespace DIWAGIS.ApplicationLayer.QuanLyMangCapNuoc
{
    public partial class frmThongTinSLNuocKhachHang : Form
    {
        public frmThongTinSLNuocKhachHang()
        {
            
            InitializeComponent();
        }
        string sTableName = generalVariable.database + "." + generalVariable.schema + "." + ClassVariables.tbSLNuocKhachHang;
        public string db;
        public string tentb;
        IFeatureWorkspace pFWS = DIWAGIS.Modules.generalVariable.ICurrentWorkspace as IFeatureWorkspace;
        private void frmThongTinSLNuocKhachHang_Load(object sender, EventArgs e)
        {

            if (db != "")
            {
                string str = "DBDongHoNuoc='" + db + "'";
                ITable ptable = pFWS.OpenTable(sTableName) as ITable;
                IQueryFilter pQuery = new QueryFilterClass();
                pQuery.WhereClause = str;
                ICursor pCusor = ptable.Search(pQuery, false);
                IRow prow = pCusor.NextRow() as IRow;
                //IRow pRow = (IRow)pCursor.NextRow();
                int thang = DateTime.Now.Month;
                if (prow != null)
                {
                    TenThueBao.Text = tentb;
                    DBDongHoNuoc.Text = db;
                    if (prow.get_Value(ptable.Fields.FindField("SLThang01")).ToString() != null)
                    {
                        SLThang01.Text = prow.get_Value(ptable.Fields.FindField("SLThang01")).ToString();
                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang02")).ToString() != null)
                    {
                        if (thang < 2)
                        {
                            SLThang02.Text = prow.get_Value(ptable.Fields.FindField("SLThang02")).ToString();
                            SLThang02.ForeColor=Color.Red;
                        }
                        else
                        {
                            SLThang02.Text = prow.get_Value(ptable.Fields.FindField("SLThang02")).ToString();  
                        }
                    }

                    if (prow.get_Value(ptable.Fields.FindField("SLThang03")).ToString() != null)
                    {
                        if (thang < 3)
                        {
                            SLThang03.ForeColor = Color.Blue;
                            SLThang03.Text = prow.get_Value(ptable.Fields.FindField("SLThang03")).ToString();
                        }
                        else
                        {
                            SLThang03.Text = prow.get_Value(ptable.Fields.FindField("SLThang03")).ToString();
                        }
                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang04")).ToString() != null)
                    {
                        if (thang < 4)
                        {
                            SLThang04.ForeColor = Color.Blue;
                            SLThang04.Text = prow.get_Value(ptable.Fields.FindField("SLThang04")).ToString();
                        }
                        else
                        {
                            SLThang04.Text = prow.get_Value(ptable.Fields.FindField("SLThang04")).ToString();
                        }
                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang05")).ToString() != null)
                    {
                        if ( thang<5 )
                        {
                            SLThang05.ForeColor = Color.Blue;
                        SLThang05.Text = prow.get_Value(ptable.Fields.FindField("SLThang05")).ToString();
                        }
                        else
                        {
                            SLThang05.Text = prow.get_Value(ptable.Fields.FindField("SLThang05")).ToString();
                        }

                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang06")).ToString() != null)
                    {
                        if (thang < 6)
                        {
                            SLThang06.ForeColor = Color.Blue;
                            SLThang06.Text = prow.get_Value(ptable.Fields.FindField("SLThang06")).ToString();
                        }
                        else
                        {
                            SLThang06.Text = prow.get_Value(ptable.Fields.FindField("SLThang06")).ToString();
                        }
                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang07")).ToString() != null)
                    {
                        if (thang < 7)
                        {
                            SLThang07.ForeColor = Color.Blue;
                            SLThang07.Text = prow.get_Value(ptable.Fields.FindField("SLThang07")).ToString();
                        }
                        else
                        {
                            SLThang07.Text = prow.get_Value(ptable.Fields.FindField("SLThang07")).ToString();
                        }
                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang08")).ToString() != null)
                    {
                        if (thang < 8)
                        {
                            SLThang08.ForeColor = Color.Blue;
                            SLThang08.Text = prow.get_Value(ptable.Fields.FindField("SLThang08")).ToString();
                        }
                        else
                        {
                            SLThang08.Text = prow.get_Value(ptable.Fields.FindField("SLThang08")).ToString();
                        }

                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang09")).ToString() != null)
                    {
                        if (thang < 9)
                        {
                            SLThang09.ForeColor = Color.Blue;
                            SLThang09.Text = prow.get_Value(ptable.Fields.FindField("SLThang09")).ToString();
                        }
                        else
                        {
                            SLThang09.Text = prow.get_Value(ptable.Fields.FindField("SLThang09")).ToString();
                        }

                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang10")).ToString() != null)
                    {
                        if (thang < 10)
                        {
                            SLThang10.ForeColor = Color.Blue;
                            SLThang10.Text = prow.get_Value(ptable.Fields.FindField("SLThang10")).ToString();
                        }
                        else
                        {
                            SLThang10.Text = prow.get_Value(ptable.Fields.FindField("SLThang10")).ToString();
                        }

                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang11")).ToString() != null)
                    {

                        if (thang < 11)
                        {
                            SLThang11.ForeColor = Color.Blue;
                            SLThang11.Text = prow.get_Value(ptable.Fields.FindField("SLThang11")).ToString();
                        }
                        else
                        {
                            SLThang11.Text = prow.get_Value(ptable.Fields.FindField("SLThang11")).ToString();
                        }
                    }
                    if (prow.get_Value(ptable.Fields.FindField("SLThang12")).ToString() != null)
                    {

                        if (thang < 12)
                        {
                            SLThang12.ForeColor = Color.Blue;
                            SLThang12.Text = prow.get_Value(ptable.Fields.FindField("SLThang12")).ToString();
                        }
                        else
                        {
                            SLThang12.Text = prow.get_Value(ptable.Fields.FindField("SLThang12")).ToString();
                        }

                    }
                  

                    
                }
            }

        }

        private void buttonDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
